package com.gc.ip;

import java.awt.Component;

import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;


@SuppressWarnings("serial")
public class JIPAddressCellEditor extends AbstractCellEditor implements TableCellEditor
{
	private JIPAddress jIPAddressComp = null;

	public JIPAddressCellEditor(JIPAddress ipAddress)
	{
		this.jIPAddressComp = ipAddress;
	}
	public JIPAddressCellEditor()
	{
		this.jIPAddressComp = new JIPAddress();
	}
	@Override
	public Object getCellEditorValue()
	{
		return jIPAddressComp.getIPAddress();
	}

	@Override
	public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
		int row, int column)
	{
		IPAddress ip = null;
		if(value instanceof IPAddress)
		{
			ip = (IPAddress) value;
		}
		jIPAddressComp.setIPAddress(ip);
		
		return jIPAddressComp;
	}

}
